package com.leo;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.shape.*;
import javafx.stage.Stage;

/**
 * @ClassName PathDemo
 * @Description 路径
 * @Author wangss
 * @date 2020.07.04 17:13
 * @Version 1.0
 */
public class PathDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane an = new AnchorPane();

        HBox hBox = new HBox(200);
        hBox.setAlignment(Pos.CENTER);

        Path path = new Path();

        MoveTo moveTo = new MoveTo(0, 0);

        LineTo lineTo = new LineTo(100, 0);

        QuadCurveTo qct = new QuadCurveTo(0, 0, 100, 100);
        // 相对位置
        qct.setAbsolute(false);

        HLineTo hLineTo = new HLineTo(100);
        hLineTo.setAbsolute(false);

        CubicCurveTo curveTo = new CubicCurveTo(50, -50, 150, 50, 200, 0);
        curveTo.setAbsolute(false);

        VLineTo vLineTo = new VLineTo(100);
        vLineTo.setAbsolute(false);

        ArcTo arcTo = new ArcTo(100, 100, 0, 100, 100, true, true);
        arcTo.setAbsolute(false);

        ClosePath closePath = new ClosePath();

        path.getElements().addAll(moveTo, lineTo, qct, hLineTo, curveTo, vLineTo, arcTo, closePath);


        hBox.getChildren().add(path);

        an.getChildren().add(hBox);
        AnchorPane.setTopAnchor(hBox, 50d);
        AnchorPane.setLeftAnchor(hBox, 50d);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1500d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }
}
